<template>
	<view class="content shareBg">
		<view class="shareBox flex-cc">
			<canvas canvas-id="qrcode" class="qrcodeCvs"/>
			<view class="desc">分享二维码给别人，一起加入赚流量</view>
			<view class="copy" @click="copy()">复制链接</view>
		</view>
	</view>
</template>

<script>
	import common from '@/static/js/common.js';
	import uQRCode from '@/static/js/uqrcode.js';
	
	export default {
		data() {
			return {
				url: '',
			}
		},
		mounted() {
			this.getUserMsgInfo()
		},
		methods: {
			getUserMsgInfo() {
				let that = this;
				common.api({
					method: 'GET',
					url: '/mobile/user/index',
					success:(res) => {
						if (res.code != 0) {
							uni.showToast({ title: res.msg, icon: 'none' });
							return false;
						}
						that.qrcode(res.data.mobile)
					}
				});
			},
			qrcode(account) {
				let that = this;
				that.url = getApp().globalData.HREF+'/pages/login/register?account='+account
				uQRCode.make({
					canvasId: 'qrcode',
					text: that.url,
					size: 160,
					margin: 10,
					success: res => {},
					complete: () => {}
				})
			},
			copy() {
				let that = this
				uni.setClipboardData({
					data: that.url,
					success: () => {}
				});
			},
		}
	}
</script>

<style lang="less" scoped>
	.shareBg {
		width: 100%;
		min-height: 100vh;
		background: url(@/static/image/share-bg.jpg) no-repeat center;
		background-size: 100% 100%;
	}
	.shareBox {
		padding: 50rpx 0;
		display: flex;
		align-items: center;
		flex-direction: column;
		color: #fff;
		position: relative;
		top: 60vh;
		.qrcodeCvs {
			display: block;
			width: 160px;
			height: 160px;
		}
		.desc {
			margin: 30rpx 0;
		}
		.copy {
			color: #999;
			font-size: 26rpx;
		}
	}
</style>
